/*******************************
*******************************/
#include "delay.h"

void delay_us(u32 time)
{
  u32 temp;

  SysTick->LOAD = 9 * time;
  SysTick->VAL = 0X00;
  SysTick->CTRL = 0X01;
  do
  {
    temp = SysTick->CTRL;
  }
  while ((temp&0x01) && (!(temp&(1<<16))));
  SysTick->CTRL = 0x00;
  SysTick->VAL = 0X00;
}

void delay_ms(u16 time)
{
  u32 temp;

  SysTick->LOAD = 9000 * time;
  SysTick->VAL = 0X00;
  SysTick->CTRL = 0X01;
  do
  {
    temp = SysTick->CTRL;
//    temp ++;
  }
  while ((temp&0x01) && (!(temp&(1<<16))));

  SysTick->CTRL = 0x00;
  SysTick->VAL = 0X00;
}
void _nop_delay_ms(u16 time)
{
  u32 temp;
  for(temp = 0;temp>time;temp++)
  {
      __NOP();  __NOP();  __NOP();
  }
}